#include "proto/internal.pb.h"
#include "Op.h"
#include "OpScan.h"
#include "OpCompute.h"
#include "OpFilter.h"
#include "OpGroupBy.h"
#include "OpOutput.h"
#include "OpConsume.h"

using namespace internal;

Op* createOp(const Operation& operation) {
	if (operation.has_scan()) return new OpScan(operation.scan());
	else if (operation.has_compute()) return new OpCompute(operation.compute());
	else if (operation.has_filter()) return new OpFilter(operation.filter());
	else if (operation.has_group_by()) return new OpGroupBy(operation.group_by()) ;
	else assert(false);
}

Op* createTaskOp(const Task& operation) {
	if (operation.has_intermediate_task()) return new OpOutput(operation.intermediate_task());
	else if (operation.has_final_task()) return new OpConsume(operation.final_task());
	else assert(false);
}
